package com.tueye.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tueye.base.util.BaseDao;
import com.tueye.base.util.IBaseHbnDao;
import com.tueye.base.util.Page;
import com.tueye.dao.ISysDicDao;
import com.tueye.entity.SysDic;
import com.tueye.entity.SysDicValue;

/**
 * 
 * @author hxw
 * 
 */
@Scope("prototype")
@Component("sysDicDao")
public class SysDicDaoImpl extends BaseDao implements ISysDicDao {

	@Autowired
	@Qualifier("baseHbnDao")
	private IBaseHbnDao baseHbnDao;

	@Override
	public void addSysDic(SysDic sysDic) {

		baseHbnDao.saveOrUpdate(sysDic);
	}

	@Override
	public void delSysDic(String id) {

		SysDic sysDic = (SysDic) baseHbnDao.findById(SysDic.class, id);
		baseHbnDao.delete(sysDic);
	}

	@Override
	public SysDic getSysDicById(String id) {

		return (SysDic) baseHbnDao.findById(SysDic.class, id);
	}

	@Override
	public Page pagedQueryByHQL(String hql, int pageNo, int pageSize,
			Object... values) {

		return baseHbnDao.pagedQueryByHQL(hql, pageNo, pageSize, values);
	}

	@Override
	public void addSysDicValue(SysDicValue sysDicValue) {
		baseHbnDao.saveOrUpdate(sysDicValue);
	}

	@Override
	public List<SysDic> getSysDicByAll() {
		// TODO Auto-generated method stub
		return baseHbnDao.queryList("from SysDic");
	}

	@Override
	public List<SysDicValue> getSysDicValueByHql(String hql) {
		
		return baseHbnDao.queryList(hql);
	}

	@Override
	public SysDicValue getSysDicValueById(String id) {
		// TODO Auto-generated method stub
		return (SysDicValue) baseHbnDao.findById(SysDicValue.class, id);
	}

	@Override
	public void delSysDicValue(String id) {
		SysDicValue sysDicValue = (SysDicValue) baseHbnDao.findById(SysDicValue.class, id);
		baseHbnDao.delete(sysDicValue);
	}

	@Override
	public void delSysDicBySysDicValue(String hql) {
		List list = baseHbnDao.queryList(hql);
		baseHbnDao.deleteAll(list);
	}

}
